package cn.zbh.org.service.impl;

import cn.zbh.basic.service.impl.BasicServiceImpl;
import cn.zbh.basic.util.PageList;
import cn.zbh.org.domain.Employee;
import cn.zbh.org.mapper.EmployeeMapper;
import cn.zbh.org.query.EmployeeQuery;
import cn.zbh.org.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class EmployeeServiceImpl extends BasicServiceImpl<Employee> implements IEmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;
    @Override
    public void add(Employee employee) {
        employeeMapper.add(employee);
        employeeMapper.addEmp2Role(employee.getId(),employee.getRole_id());


    }

    @Override
    public void update(Employee employee) {
        //修改
        employeeMapper.update(employee);
        employeeMapper.delEmp2Role(employee.getId());
        employeeMapper.addEmp2Role(employee.getRole_id(),employee.getRole_id());
    }

    @Override
    public void delete(long eid) {
        employeeMapper.delete(eid);
        employeeMapper.delEmp2Role(eid);
    }
}
